<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head th:replace="nav :: navHeaderIFrameItem(~{::title})">
    <title>号段明细</title>
</head>
<body>
    <div id="form_win">
        <form class="layui-form" lay-filter="formData" >
            <div class="layui-form-item">
                <label class="layui-form-label">业务类型</label>
                <div class="layui-input-block">
                    <input type="text" name="bizType"  placeholder="业务类型" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">起始值</label>
                <div class="layui-input-block">
                    <input type="text" name="beginId" placeholder="起始值" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">步长</label>
                <div class="layui-input-block">
                    <input type="text" name="step" placeholder="步长" autocomplete="off" class="layui-input" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否初始化</label>
                <div class="layui-input-block">
                    <input type="radio" name="isNeedInit" value="1" title="server" disabled>
                    <input type="radio" name="isNeedInit" value="0" title="sdk" disabled>
                </div>
            </div>
        </form>
    </div>
    <div th:include="nav::navFooterIFrameItem" ></div>
    <script>
        //此处采用路径截取方式（可以采用thymeleaf方式）
        let url= document.location.href;
        let urlList = url.split('/');
        let id = urlList[urlList.length-1];

        layui.use(['form'], function() {
            //引入layui from模块
            let form = layui.form
            ,$ = layui.$;

            //初始化数据
            $.ajax({
                type: "get",//方法类型
                url: "/segment/detail/"+id,
                dataType: "json",//预期服务器返回的数据类型
                success:function(result){
                    if(result.code===0){
                        let data = result.data;
                        $('input[name=isNeedInit][value='+(data.isNeedInit?"1":"0")+']').removeAttr("disabled");
                        $('input[name=isNeedInit][value='+(data.isNeedInit?"1":"0")+']').attr("checked",true);
                        form.val('formData',data);
                        form.render(); //更新全部
                    }else{
                        top.layer.msg(result.msg, {
                            icon: 2,
                            time: 3000 //如果不配置，默认是3秒
                        });
                    }
                },
                error : function(e){
                    top.layer.msg('服务异常');
                }
            });

            //明细关闭
            form.on('submit(formDemo)', function(data){
                close_layer();
                return false;
            });

            //关闭弹窗
            function close_layer() {
                let index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }

        })
    </script>
</body>
</html>